package com.nameless.controller;

import com.nameless.util.UploadUtil;
import com.nameless.util.ValidateCodeUtils;
import com.nameless.util.WebUtils;
import com.nameless.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

/**
 * -*- coding:utf-8 -*-
 *
 * @author 太阳偷渡青山
 * @software IntelliJ IDEA
 * @date 2022/09/28 22:04
 * @Description
 */
@Api(value = "/common/upload", tags = {"-*- coding:utf-8 -*-"})
@Controller
@Slf4j
@RequestMapping("/common/upload")
public class UploadController {
    /**
     * 添加用户的头像上传远程
     *
     * @param file 文件
     * @return {@link Result}
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "form", dataType = "file", name = "file", value = "文件", required = true)
    })
    @ApiOperation(value = "添加用户的头像上传远程", notes = "添加用户的头像上传远程", httpMethod = "POST")
    @PostMapping("/sure")
    @ResponseBody
    public Result upload(MultipartFile file){
        String url = UploadUtil.uploadOSS(file);
        return Result.success("上传成功",url);
    }
}